package com.example.shixunandjavagotoyangchen.Sunshine.Okhttp;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

public class BasterOkhttp {

    public static  BasterOkhttp basterOkhttp;
    public Retrofit retrofit;
    public static BasterOkhttp getBasterOkhttp()
    {
        if (basterOkhttp==null){
            synchronized (BasterOkhttp.class){
                if (basterOkhttp==null){
                    basterOkhttp = new BasterOkhttp();
                }
            }
        }
        return basterOkhttp;
    }



    public Retrofit getRetrofit()
    {
        if (retrofit==null){
            synchronized (Retrofit.class){
                if (retrofit==null){
                    retrofit = new Retrofit.Builder()
                            .baseUrl("http://www.qubaobei.com/ios/cf/")
                            .client(new OkHttpClient.Builder()
                                    .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
                                    .build())
                            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                            .addConverterFactory(GsonConverterFactory.create())
                            .build();
                }
            }
        }
        return retrofit;
    }


}
